
import React, { PureComponent } from 'react'
import { Modal, Button, Col, Row } from 'antd'
import { history } from 'umi'
import { baseurl } from '@/services/baseurl'
import {countLearnTimeWithHour,hasProgressFunc,minutesToHours} from '@/utils/utils'
export default class AnalyzeModal extends PureComponent<any, any> {
    exportList=(id,is_sw)=>()=>{
        window.open(`${baseurl}index/index/derive_synthesize?id=${id}&is_sw=${is_sw}`)
    }
    render() {
        const { visible, onHide, data } = this.props;
        const sumTime = data.done_time+data.duration_total+(data.learn*1000*60)
        return (
            <Modal visible={visible} onCancel={onHide} title={<p style={{fontSize:20}}>{data.name}</p>} footer={<div>
                <div style={{float:'left'}}>
                总学习时长：{minutesToHours(sumTime)}&nbsp;&nbsp;&nbsp;&nbsp;
                {
                    hasProgressFunc()&&('学时：'+countLearnTimeWithHour((sumTime)/60/1000/60)+'学时')
                }
                
                <Button type="primary" key="1" style={{marginLeft:10,background:"#E3A869",borderColor:"#E3A869"}} onClick={this.exportList(data.id,data.is_sw)}>学习统计表导出</Button>
                </div>
                <Button type="primary" key="1" onClick={onHide}>确定</Button>
            </div>}>
                <h4 style={{fontSize:18,marginTop:'-10px'}}>{data.company||data.student_types}</h4>
                <div>
                    <h4>专项练习<Button type="primary" style={{ marginLeft: 10 }} onClick={() => history.push('/analyze/practiceAnalyze?name='+data.name)}>详情</Button></h4>
                </div>
                <Row>
                    <Col span={12}>练习科目</Col>
                    <Col span={12}>{data.subjects||0}</Col>
                    <Col span={12}>题库总数</Col>
                    <Col span={12}>{data.question_num||0}道</Col>
                    <Col span={12}>已作答</Col>
                    <Col span={12}>{data.done_num||0}道</Col>
                    <Col span={12}>完成率</Col>
                    <Col span={12}>{data.percentage||0}%</Col>
                    <Col span={12}>正确率</Col>
                    <Col span={12}>{data.rights||0}%</Col>
                    <Col span={12}>答题时长</Col>
                    <Col span={12}>{ Math.floor((data.done_time/1000/60) << 0)||0}分钟</Col>
                </Row>
                <hr />
                <div>
                    <h4>模拟考试<Button type="primary" style={{ marginLeft: 10 }} onClick={() => history.push('/analyze/examAnalyze?name='+data.name)}>详情</Button></h4>
                </div>
                <Row>
                    <Col span={12}>模拟次数</Col>
                    <Col span={12}>{data.num||0}次</Col>
                    <Col span={12}>完成率</Col>
                    <Col span={12}>{data.total||0}%</Col>
                    <Col span={12}>正确率</Col>
                    <Col span={12}>{data.correct_total||0}%</Col>
                    <Col span={12}>答题时长</Col>
                    <Col span={12}>{ Math.floor((data.duration_total/1000/60) << 0)||0}分钟</Col>
                </Row>
                <hr />
                
                <div>
                    <h4>课件学习<Button type="primary" style={{ marginLeft: 10 }} onClick={() => history.push('/analyze/learnAnalyze?name='+data.name)}>详情</Button></h4>
                </div>
                <Row>
                    <Col span={12}>学习次数</Col>
                    <Col span={12}>{data.learn_num||0}次</Col>
                    <Col span={12}>学习时长</Col>
                    <Col span={12}>{data.learn||0}分钟</Col>
                </Row>
            </Modal>
        )
    }
}
